Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
"getElementByTagName" para agregar nodos a una lista

Estoy tratando de agregar un elemento de lista a mi lista Ordenada capturando el elemento de lista en javaScript usando 'getElementByTagName' pero está dando un error:

list.appendChild is not a function

 { let btn = document.getElementById("btn"); let list = document.getElementsByTagName("ol"); btn.onclick = function(){ let node = document.createElement("li").appendChild(document.createTextNode("new item")); list.appendChild(node); } }
 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>My Website</title> <script defer src = "js/index.js"></script> <link rel="stylesheet" href="css/style.css"> </head> <body> <ol id="items"> <li class="border">Home</li> <li>Contact</li> <li class="border" id="special">About us</li> </ol> <button id="btn"> Click me</button><br> </body> </html>

Nota: El código no da un error si capturo el 'ol' usando getElementbyId pero quiero saber por qué recibo un error con 'getElementByTagName'.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!